﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;


namespace MiaProject
{
    class Shot2D : Actor2D
    {
        private const float Rotation = 0;
        private const float Scale = 1.0f;
        private const float Depth = 0.5f;
        public int frames;
        public int framesPerSec;
        public const int SHOT_MOVE = 0;
        public const int SHOT_EXPLODE = 1;
        
        public bool status;
        public Vector2 pos;
        public Vector2 lastPos;
        public Vector2 dir;
        public int vel;

        public Shot2D()
        {
            SpriteTexture = new AnimatedTexture(Vector2.Zero,Rotation, Scale, Depth);
            this.frames = 5;
            this.framesPerSec = 5;
            this.animation = new int[1,2];

            this.animation[SHOT_MOVE, 0] = 0;
            this.animation[SHOT_MOVE, 1] = 4;

            this.status = true;
            this.currentAnim = -1;

            lastPos = Vector2.Zero;
            pos = new Vector2(100, 100);

            this.dir = new Vector2(0, 0);
            this.vel = 500;
            
        }
        public bool animEnded()
        {
            return SpriteTexture.animEndend;
        }
        public void setAnimExplode()
        {
            if (this.currentAnim == SHOT_EXPLODE)
                return;
            this.currentAnim = SHOT_EXPLODE;
            SpriteTexture.setAnim(getAnimI(), getAnimF());
        }
        public void setAnimMove()
        {
            if (this.currentAnim == SHOT_MOVE)
                return;
            this.currentAnim = SHOT_MOVE;
            SpriteTexture.setAnim(getAnimI(), getAnimF());
        }
        public void update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            this.lastPos.X = this.pos.X;
            this.lastPos.Y = this.pos.Y;
            this.pos.X += this.dir.X * vel * elapsed;
            this.pos.Y += this.dir.Y * vel * elapsed;

        }
        /*public bool isSended()
        {
            if(SpriteTexture.Frame >= 23)
                return true;
            return false;
        }*/
        
    }
}
